package cn.gzjp.modules.woms.entity;

import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.google.common.collect.Lists;
import org.hibernate.validator.constraints.Length;
import java.util.Date;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;
//import org.hibernate.validator.constraints.Length(min=0, max=256, message="工程师;

import cn.gzjp.common.persistence.DataEntity;
import cn.gzjp.common.utils.excel.annotation.ExcelField;

/**
 * 工单Entity
 * @author liyp
 * @version 2018-07-07
 */
public class Event extends DataEntity<Event> {
	
	private static final long serialVersionUID = 1L;
	private String status;		// 最新状态
	private String deviceId;		// 设备id
	private String deviceName;		// 设备名称
	private String subordinateUnits;		// 所属单位
	private String computerRoom;		// 接入机房
	private String route;		// 网络路由
	private String ip;		// IP地址
	private String operationArea;		// 运营片区
	private String installPosition;		// 安装位置
	private String powerPosition;		// 取电位置
	private String faultType;		// 故障类型
	private String faultChannel;		// 故障通道
	private String faultPic;		// 故障图片
	private String longitude;//故障位置经度(用于导航)
	private String latitude;//故障纬度
	private String address;//故障地址

	private Worker assigner;		// 分派员
	private Date assignTime;		// 分派时间
	private String engineerIds;		// 工程师(可多个)

	private String zrgsType;		// 责任归属
	private String zrgsDesc;		// 责任归属描述
	private String faultDesc;		// 故障描述
	private String lwpqType;		// 劳务派遣类型
	private String lwpqDesc;		// 劳务派遣描述
	private String receiverId;		// 工单接收者
	private Date receiveTime;		// 接收时间
	private Date finishTime;		// 处理完成时间

	private List<EventProcess> processList = Lists.newArrayList();//工单处理流程

	private String enginnerId;//工程师,用于查询

	private String engineerUndo; //工程师为处理,用于查询（status为2）
	private String engineerDoing;//处理中（status为 34）
	private String engineerDone;//已处理（status为 5）
	private String pmUnfinish;//未完成（status为 1234）

	private String assignerDone;//分派员已处理(status为 2345)

	private String createrId;//创建者id （用于批量导入）

	private List<String> inProjects;//用于查询

	private String achieve;//0 未核实 1已核实

	private String transType;//传输类型


	private String currentStatus;//查询条件  1新建(1) 2 处理中(2,3,4,5,6)  3已完成(7)




	public String getEngineerIds() {
		return engineerIds;
	}

	public void setEngineerIds(String engineerIds) {
		this.engineerIds = engineerIds;
	}


	public Worker getAssigner() {
		return assigner;
	}

	public void setAssigner(Worker assigner) {
		this.assigner = assigner;
	}



	public Event() {
		super();
	}

	public Event(String id){
		super(id);
	}

	@Length(min=0, max=1, message="最新状态长度必须介于 0 和 1 之间")
	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	@Length(min=0, max=256, message="设备名称长度必须介于 0 和 256 之间")
	@ExcelField(title="设备名称", align=2, sort=15)
	public String getDeviceName() {
		return deviceName;
	}

	@Length(min=0, max=32, message="设备id长度必须介于 0 和 32 之间")
	@ExcelField(title="设备编号", align=2, sort=20)
	public String getDeviceId() {
		return deviceId;
	}

	public void setDeviceId(String deviceId) {
		this.deviceId = deviceId;
	}
	@ExcelField(title="传输类型", align=2, sort=25)
	public String getTransType() {
		return transType;
	}

	public void setTransType(String transType) {
		this.transType = transType;
	}

	public void setDeviceName(String deviceName) {
		this.deviceName = deviceName;
	}
	
	@Length(min=0, max=256, message="所属单位长度必须介于 0 和 256 之间")
	@ExcelField(title="所属单位", align=2, sort=30)
	public String getSubordinateUnits() {
		return subordinateUnits;
	}

	public void setSubordinateUnits(String subordinateUnits) {
		this.subordinateUnits = subordinateUnits;
	}
	
	@Length(min=0, max=256, message="接入机房长度必须介于 0 和 256 之间")
	@ExcelField(title="接入机房", align=2, sort=40)
	public String getComputerRoom() {
		return computerRoom;
	}

	public void setComputerRoom(String computerRoom) {
		this.computerRoom = computerRoom;
	}
	
	@Length(min=0, max=256, message="网络路由长度必须介于 0 和 256 之间")
	@ExcelField(title="网络路由", align=2, sort=50)
	public String getRoute() {
		return route;
	}

	public void setRoute(String route) {
		this.route = route;
	}
	
	@Length(min=0, max=32, message="IP地址长度必须介于 0 和 32 之间")
	@ExcelField(title="IP地址", align=2, sort=60)
	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}
	
	@Length(min=0, max=256, message="运营片区长度必须介于 0 和 256 之间")
	@ExcelField(title="所属项目", align=2, sort=70)
	public String getOperationArea() {
		return operationArea;
	}

	public void setOperationArea(String operationArea) {
		this.operationArea = operationArea;
	}
	
	@Length(min=0, max=256, message="安装位置长度必须介于 0 和 256 之间")
	@ExcelField(title="安装位置", align=2, sort=80)
	public String getInstallPosition() {
		return installPosition;
	}

	public void setInstallPosition(String installPosition) {
		this.installPosition = installPosition;
	}
	
	@Length(min=0, max=256, message="取电位置长度必须介于 0 和 256 之间")
	@ExcelField(title="取电位置", align=2, sort=90)
	public String getPowerPosition() {
		return powerPosition;
	}

	public void setPowerPosition(String powerPosition) {
		this.powerPosition = powerPosition;
	}
	
	@Length(min=0, max=128, message="故障类型长度必须介于 0 和 128 之间")
	@ExcelField(title="故障类型", align=2, sort=100)
	public String getFaultType() {
		return faultType;
	}

	public void setFaultType(String faultType) {
		this.faultType = faultType;
	}
	
	@Length(min=0, max=128, message="故障通道长度必须介于 0 和 128 之间")
	//@ExcelField(title="故障通道", align=2, sort=110)
	public String getFaultChannel() {
		return faultChannel;
	}

	public void setFaultChannel(String faultChannel) {
		this.faultChannel = faultChannel;
	}
	
	@Length(min=0, max=256, message="故障图片长度必须介于 0 和 256 之间")
	@ExcelField(title="图片名称", align=2, sort=110)
	public String getFaultPic() {
		return faultPic;
	}

	public void setFaultPic(String faultPic) {
		this.faultPic = faultPic;
	}
	

	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	public Date getAssignTime() {
		return assignTime;
	}

	public void setAssignTime(Date assignTime) {
		this.assignTime = assignTime;
	}
	

	
	@Length(min=0, max=32, message="责任归属长度必须介于 0 和 32 之间")
	public String getZrgsType() {
		return zrgsType;
	}

	public void setZrgsType(String zrgsType) {
		this.zrgsType = zrgsType;
	}
	
	@Length(min=0, max=512, message="责任归属描述长度必须介于 0 和 512 之间")
	public String getZrgsDesc() {
		return zrgsDesc;
	}

	public void setZrgsDesc(String zrgsDesc) {
		this.zrgsDesc = zrgsDesc;
	}
	
	@Length(min=0, max=512, message="故障描述长度必须介于 0 和 512 之间")
	public String getFaultDesc() {
		return faultDesc;
	}

	public void setFaultDesc(String faultDesc) {
		this.faultDesc = faultDesc;
	}
	
	@Length(min=0, max=32, message="劳务派遣长度必须介于 0 和 32 之间")
	public String getLwpqType() {
		return lwpqType;
	}

	public void setLwpqType(String lwpqType) {
		this.lwpqType = lwpqType;
	}
	
	@Length(min=0, max=512, message="劳务派遣描述长度必须介于 0 和 512 之间")
	public String getLwpqDesc() {
		return lwpqDesc;
	}

	public void setLwpqDesc(String lwpqDesc) {
		this.lwpqDesc = lwpqDesc;
	}
	
	@Length(min=0, max=32, message="工单接收者长度必须介于 0 和 32 之间")
	public String getReceiverId() {
		return receiverId;
	}

	public void setReceiverId(String receiverId) {
		this.receiverId = receiverId;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	public Date getReceiveTime() {
		return receiveTime;
	}

	public void setReceiveTime(Date receiveTime) {
		this.receiveTime = receiveTime;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	public Date getFinishTime() {
		return finishTime;
	}

	public void setFinishTime(Date finishTime) {
		this.finishTime = finishTime;
	}

	//用于导入导出,关联故障图片
	//@ExcelField(title="工单编号", align=2, sort=10)
	public String getEventId() {
		return this.getId();
	}

	public void setEventId(String eventId) {
		this.id = eventId;
	}

	public List<EventProcess> getProcessList() {
		return processList;
	}

	public void setProcessList(List<EventProcess> processList) {
		this.processList = processList;
	}

	public String getEnginnerId() {
		return enginnerId;
	}

	public void setEnginnerId(String enginnerId) {
		this.enginnerId = enginnerId;
	}

	public String getEngineerUndo() {
		return engineerUndo;
	}

	public void setEngineerUndo(String engineerUndo) {
		this.engineerUndo = engineerUndo;
	}

	public String getEngineerDoing() {
		return engineerDoing;
	}

	public void setEngineerDoing(String engineerDoing) {
		this.engineerDoing = engineerDoing;
	}

	public String getEngineerDone() {
		return engineerDone;
	}

	public void setEngineerDone(String engineerDone) {
		this.engineerDone = engineerDone;
	}

	public String getPmUnfinish() {
		return pmUnfinish;
	}

	public void setPmUnfinish(String pmUnfinish) {
		this.pmUnfinish = pmUnfinish;
	}

	@ExcelField(title="经度", align=2, sort=120)
	public String getLongitude() {
		return longitude;
	}

	public void setLongitude(String longitude) {
		this.longitude = longitude;
	}
	@ExcelField(title="纬度", align=2, sort=130)
	public String getLatitude() {
		return latitude;
	}

	public void setLatitude(String latitude) {
		this.latitude = latitude;
	}
	//@ExcelField(title="地址", align=2, sort=140)
	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getAssignerDone() {
		return assignerDone;
	}

	public void setAssignerDone(String assignerDone) {
		this.assignerDone = assignerDone;
	}

	public String getCreaterId() {
		return createrId;
	}

	public void setCreaterId(String createrId) {
		this.createrId = createrId;
	}

	public List<String> getInProjects() {
		return inProjects;
	}

	public void setInProjects(List<String> inProjects) {
		this.inProjects = inProjects;
	}


	private long leftMinutes;

	private String leftTime;

	public String getLeftTime() {
		if(this.getLeftMinutes()!=100000){
			return this.getLeftMinutes()/60+":"+this.getLeftMinutes()%60;
		}
		return "00:00";
	}

	public void setLeftTime(String leftTime) {
		this.leftTime = leftTime;
	}

	public long getLeftMinutes() {
		Date tomorrow = DateUtil.offsetDay(this.getCreateDate(),1);
		if(tomorrow.after(new Date())){
			return DateUtil.between(tomorrow,new Date(), DateUnit.MINUTE);
		}
		return 100000;
	}

	public void setLeftMinutes(long leftMinutes) {
		this.leftMinutes = leftMinutes;
	}


	public String getAchieve() {
		return achieve;
	}

	public void setAchieve(String achieve) {
		this.achieve = achieve;
	}


	public String getCurrentStatus() {
		return currentStatus;
	}

	public void setCurrentStatus(String currentStatus) {
		this.currentStatus = currentStatus;
	}
}